<template>
	<div class="registerStep">
		<div class="container">
			<div class="rows">
				<div class="title">附件信息</div>
				<div class="row">
					<div class="label">营业执照:</div>
					<div class="value">
						<div class="images">
							<div class="image" v-for="(item,index) in businessLicenses" :key="item">
								<image :src="item" @click="previewBusinessLicensesImage(index)"/>
								<div class="imageDel" @click.stop="delBusinessLicensesImage(index)">
									<uni-icons type="clear" size="48rpx" color="red"></uni-icons>
								</div>
							</div>
							<div class="imageAdd" @click="chooseBusinessLicensesImage()">
								<uni-icons type="plusempty" size="48rpx" color="#8f939c"></uni-icons>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="label">开户许可证:</div>
					<div class="value">
						<div class="images">
							<div class="image" v-for="(item,index) in accountOpeningLicenses" :key="item">
								<image :src="item" @click="previewAccountOpeningLicensesImage(index)"/>
								<div class="imageDel" @click.stop="delAccountOpeningLicensesImage(index)">
									<uni-icons type="clear" size="48rpx" color="red"></uni-icons>
								</div>
							</div>
							<div class="imageAdd" @click="chooseAccountOpeningLicensesImage()">
								<uni-icons type="plusempty" size="48rpx" color="#8f939c"></uni-icons>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="label">经办人身份证:</div>
					<div class="value">
						<div class="images">
							<div class="image" v-for="(item,index) in operatorIDCards" :key="item">
								<image :src="item" @click="previewOperatorIDCardsImage(index)"/>
								<div class="imageDel" @click.stop="delOperatorIDCardsImage(index)">
									<uni-icons type="clear" size="48rpx" color="red"></uni-icons>
								</div>
							</div>
							<div class="imageAdd" @click="chooseOperatorIDCardsImage()">
								<uni-icons type="plusempty" size="48rpx" color="#8f939c"></uni-icons>
							</div>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="label">其他附件:</div>
					<div class="value">
						<div class="images">
							<div class="image" v-for="(item,index) in others" :key="item">
								<image :src="item" @click="previewOthersImage(index)"/>
								<div class="imageDel" @click.stop="delOthersImage(index)">
									<uni-icons type="clear" size="48rpx" color="red"></uni-icons>
								</div>
							</div>
							<div class="imageAdd" @click="chooseOthersImage()">
								<uni-icons type="plusempty" size="48rpx" color="#8f939c"></uni-icons>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="footer">
				<div class="btn" @click="submit">提交审核</div>
			</div>
		</div>
		<safe-area></safe-area>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				businessLicenses: [],
				accountOpeningLicenses: [],
				operatorIDCards: [],
				others: [],
			}
		},
		methods: {
			chooseBusinessLicensesImage() {
				uni.chooseImage({
					success: (e) => {
						e.tempFilePaths.forEach(x => {
							this.businessLicenses.push(x);
						})
					}
				})
			},
			delBusinessLicensesImage(idx) {
				this.businessLicenses.splice(idx, 1);
			},
			previewBusinessLicensesImage(idx) {
				uni.previewImage({
					urls: this.businessLicenses,
					current: idx,
				})
			},
			chooseAccountOpeningLicensesImage() {
				uni.chooseImage({
					success: (e) => {
						e.tempFilePaths.forEach(x => {
							this.accountOpeningLicenses.push(x);
						})
					}
				})
			},
			delAccountOpeningLicensesImage(idx) {
				this.accountOpeningLicenses.splice(idx, 1);
			},
			previewAccountOpeningLicensesImage(idx) {
				uni.previewImage({
					urls: this.accountOpeningLicenses,
					current: idx,
				})
			},
			chooseOperatorIDCardsImage() {
				uni.chooseImage({
					success: (e) => {
						e.tempFilePaths.forEach(x => {
							this.operatorIDCards.push(x);
						})
					}
				})
			},
			delOperatorIDCardsImage(idx) {
				this.operatorIDCards.splice(idx, 1);
			},
			previewOperatorIDCardsImage(idx) {
				uni.previewImage({
					urls: this.operatorIDCards,
					current: idx,
				})
			},
			chooseOthersImage() {
				uni.chooseImage({
					success: (e) => {
						e.tempFilePaths.forEach(x => {
							this.others.push(x);
						})
					}
				})
			},
			delOthersImage(idx) {
				this.others.splice(idx, 1);
			},
			previewOthersImage(idx) {
				uni.previewImage({
					urls: this.others,
					current: idx,
				})
			},
			submit() {

			},
		}
	}
</script>

<style lang="scss" scoped>
	.registerStep {
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: center;

		.container {
			flex: 1;
			width: 100%;
			overflow-y: auto;
			display: flex;
			flex-direction: column;
			align-items: center;

			.rows {
				width: 680rpx;
				display: flex;
				flex-direction: column;
				font-size: 26rpx;

				.title {
					padding: 32rpx 0;
					border-bottom: 1px solid $uni-border-2;
				}

				.row {
					box-sizing: border-box;
					display: flex;
					flex-direction: column;

					.label {
						margin-bottom: 36rpx;
						padding: 16rpx 0;
						flex-shrink: 0;
					}

					.value {
						width: 100%;

						.images {
							width: 100%;
							display: flex;
							align-items: center;
							flex-wrap: wrap;
							gap: 40rpx;

							.image {
								width: 200rpx;
								height: 200rpx;
								flex-shrink: 0;
								box-sizing: border-box;
								border: 1px dashed $uni-border-3;
								display: flex;
								justify-content: center;
								align-items: center;
								position: relative;

								image {
									width: 100%;
									height: 100%;
								}

								.imageDel {
									position: absolute;
									top: 0;
									right: 0;
									transform: translate(50%, -50%);
								}
							}

							.imageAdd {
								width: 200rpx;
								height: 200rpx;
								box-sizing: border-box;
								border: 1px dashed $uni-border-3;
								display: flex;
								justify-content: center;
								align-items: center;
							}
						}
					}
				}
			}

			.footer {
				width: 100%;
				padding: 50rpx 0;
				display: flex;
				justify-content: center;
				align-items: center;

				.btn {
					width: 480rpx;
					height: 80rpx;
					border-radius: 80rpx;
					background-color: $uni-primary;
					color: white;
					display: flex;
					justify-content: center;
					align-items: center;
				}
			}
		}
	}
</style>